perm filename JOIN[E,ALS] blob
sn#204969 filedate 1976-03-12 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 JOIN BREAKL
C00011 ENDMK
Cā;
;JOIN BREAKL
;JOIN joins lines (gets rid of CRLF's) without any other changes to the text
;TABs are left as TABs and may occupy a differing number of displayed spaces
;The resulting line may contain as many as 131,069 chars.
JOIN: TRNN F,ARG ;Is there an argument?
MOVEI A,2 ;Default value is 2 for JOIN
SKIPG A
POPJ P, ;Abort on 0 or neg argument
MOVEM A,JCNT# ;Count of lines to be joined into JCNT.
JOIN0: PUSHJ P,ENDSET ;To guarentee that new line will be at the end of FS
TLO F,NOCHK ;Don't CORE DOWN untill through
TRNE F,ATTMOD ;Are we in ATTACH mode?
SKIPA E,[JATAB] ; Yes so put [JATAB] in E.
MOVEI E,JPTAB ; No so put [JPTAB] in E.
HRRZ A,@JPT1(E) ;Put right of @ATTBUF or @ARRLIN in A
MOVEM A,JPTR ;Address of link word for first line of text
MOVE G,TXTCNT(A) ;Accumulate stored char count in G
HLLZ Q,TXTFLG(A) ;Save flags
;Link up start of new area in place of the old
HRRZ H,FSEND
ADDI H,1
MOVEM H,JLPT
HLLZ TT,(A) ;Use the left half of old link for
LEG MOVEM TT,(H) ;left half of the new link word, zero right
HLRZ T,TT
HRRM H,(T) ;Fix earlier forward link to the new line
LEG HLLM Q,TXTFLG(H) ;Use old flags
AOS TT,TXTNUM
LEG HRRM TT,TXTSER(H) ;Assign H new serial number
TLNE Q,ARRBIT ;May need to reset ARRLIN
MOVEM H,ARRLIN
TLNE Q,WINBIT ;and also WINLIN
MOVEM H,WINLIN
ADD H,[440700,,LLDESC] ;Pointer for depositing text
CAIN T,PAGE
TRO F,UPDTXT ;This is the first line on the page
SETZB B,Q ;For B count and word count
JOIN1: HRRZ T,TXTCNT(A) ;Is this a null line?
JUMPE T,JOIN4 ;Yes
MOVE D,A
ADD D,[440700,,LLDESC] ;Pointer to read text
JRST JOIN3
;Transfer text, counting chars and fixing up TABs
JOIN2:
LEG IDPB C,H
JOIN3: ILDB C,D
CAIN C,11 ;Is it a TAB?
JRST JOIN5 ;Yes
CAIE C,15 ;Looking for end of input line
AOJA B,JOIN2 ;B value must be accumulated
JOIN4: AOS Q ;Count input line
;Test for end of text and fix up for next line
HRRZ A,(A) ;Look at next line
CAMN A,JETST(E) ;Are we at BOTSTR or ATTBUF?
JRST JOIN6 ;Yes! we must stop
SOSG JCNT ;Have we joined the specified number of lines?
JRST JOIN6 ;Yes
SOS @JLPTR(E) ;1 line removed from LINES or ATTNUM
ADD G,TXTCNT(A) ;Add stored count record
SUB G,[2,,] ;Less CRLF
SOS @JCPTR(E) ;But correct CHARS or ATTSIZ now
SOS @JCPTR(E) ;for both CR and LF that will be deleted
JRST JOIN1
;Routine for fixing TABs
JOIN5: ILDB C,D ;Yes
CAIN C,40
JRST .-2 ;Eat original spaces
CAIE C,11 ;Spaces should terminate in a TAB
OUTSTR [ASCIZ /TAB trouble, inspect text carefully for char omission. /]
;Now put in correct number of spaces for deposited position in line
LEG IDPB C,H ;Deposit as initial TAB
HRROI TT,-10
IORI TT,(B)
SUB B,TT
MOVEI T,40
JRST .+11(TT)
REPEAT 10,<LEG IDPB T,H>
JRST JOIN2 ;B and G updated, so deposit second TAB and go on
;Now we must finish off the line
JOIN6:
MOVEI C,40
TRNN B,777777 ;Is it a null line?
LEG IDPB C,H ;Yes, 1 space is required
MOVEI C,15
LEG IDPB C,H ;The CR
MOVEI C,12
LEG IDPB C,H ;And a LF
TDZA C,C
LEG IDPB C,H ;And a null
TLNE H,760000
JRST .-2
;And complete the links to the following text
MOVE T,JLPT ;Now fix new right link
LEG HRRM A,(T)
HRLM T,(A) ;And backward link to the new line
HRR G,B ;Overwriting value in right half that is not used
LEG MOVEM G,TXTCNT(T) ;Record char counts
;Text must be in ASCID
MOVEI TT,1
ADDI T,LLDESC ;Get address of first text word
IORM TT,(T) ;Convert text words to ASCID
CAIGE T,(H)
AOJA T,.-2
MOVEI B,2(H)
MOVSI T,TXTCOD
FSFIX B,T
PUSHJ P,ENDFIX
;It should be safe to FSGIVE now, count is in Q
MOVE A,JPTR ;Get back address of first old line
PUSHJ P,FSGIVE ;And give up its space
HRRZ A,(A)
SOJG Q,.-2 ;Do this for all the old lines
TRO F,WRITE!DSPALL
TLZ F,NOCHK
MOVE T,JLPT ;Restore T value
HRRZ B,TXTCNT(T) ;and check final length of joined line
CAIG B,EDCHRL ;Is line too long for line-editor?
JRST JEXIT(E)
PUSHJ P,ABCRLF
SETZM TYOPNT
OUTSTR [ASCIZ /Joined line contains /]
TYPDEC B
OUTSTR [ASCIZ / chars and is too long for the Line-Editor./]
AOS (P)
JRST JEXIT(E)
;BREAK introduces CRLF's into a file after the specified number of chars, as
;displayed, without making any other changes. Existing CRLF's are respected
;so that some lines may be shorter than the specified length. The default
;length is set at 80, but it may be reset to any desired value up to 99,999.
BREAKL: MOVEM A,JCNT ;Save argument
MOVE T,EXTPNT ;To read break length if specified
MOVEM T,TYIPNT ;Set pointer.
HRLI C,(<MOVEI C,>)
MOVEM C,TYIINS
SETZB A,C
BREAK0: PUSHJ P,TYI ;Get first character if any.
JRST BREAK3 ;We are to use default values.
CAIN C," "
JRST BREAK0 ;Ignore an extra space in here.
MOVEI TT,5 ;Sets limit of 99999 char (20 K file)
BREAK1: CAIG C,71
CAIGE C,60
JRST BREAK2
IMULI A,12
ADDI A,-"0"(C)
PUSHJ P,TYI
JRST BREAK2
SOJG TT,BREAK1
BREAK2: CAIE C,175 ;An ALT?
SKIPG A
POPJ P, ;Abort command
MOVEM A,BREAKV ;Break value is always sticky
BREAK3: